﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace StudioEditorTest.CodeEditor
{
	public class CodeEditorListView : ListView
	{
		protected override void PrepareContainerForItemOverride(System.Windows.DependencyObject element, object item)
		{
			base.PrepareContainerForItemOverride(element, item);
			if (this.View is GridView)
			{
				int index = this.ItemContainerGenerator.IndexFromContainer(element);
				ListViewItem lvi = element as ListViewItem;
				IExtendedListViewContentItem exContainerItem = lvi.Content as IExtendedListViewContentItem;
				if (exContainerItem != null && exContainerItem.Index == -1)
				{
					exContainerItem.Index = index;
				}
			}
		}
	}
}
